/* $Id: moros.h jjs $ */
/*
   Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
   Part of the Moros Project http://moros.sourceforge.net/

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details.
*/

#ifndef MOROS_H
#define MOROS_H

#include <string>
#include <map>
#include "list_games.h"
#include "../general/communicate.h"
#include "login.h"
#include "cache.h"

#define AUTH_PORT 12001
#define DATA_PORT 12002

/** \mainpage Moros worlds of fantasy project
 *
 * \section intro_sec Introduction
 *
 * The project has different executables:
 *  moros           - client of the game
 *  moros_central   - the central server
 *  game_server     - a running game where people can connect to
 *  chat_server     - a chat server connected to a game or moros_central
 *
 * \section install_sec Installation
 *
 * This project uses a set of libaries:
 * \par - gtkmm-2.4
 * \par - gdkmm-2.4
 * \par - glademm-2.4
 * \par - gnutls
 *
 * \section gameplay_sec Game
 *
 * The user should just launch the client and can create a personal profile on the central server.
 * The following options are then open:
 * \par
 *  - join a current game, it can be rated afterwards by the player for the data to remain available
 * \par
 *  - chat with people for ideas to start a new game
 * \par
 *  - define a new game and map from scratch with the game editor
 * \par
 *  - get the data from an old game that has been played and create a new game based on that
 */

/// Data in the current game

class moros {
  public:
	moros();
	~moros();
	void config();
	std::string config_file;
	std::map<std::string, std::string> users; ///< username to password map
	std::string user; ///< current logged on user
	std::string url; ///< url to current game
    std::string central; ///< address of the central server
	communicate comm;
	channel *cent_ch; ///< Channel to the central server
	list_games *game_list;
    cache img_cache;
	bool comm_poll(); ///< routine to call a couple of times a second
	bool login_central;
	bool login_chat;
    bool login_game;
    std::string current_game;
    void config_handler(channel *ch);
    void login_handler(channel *ch);
    void data_handler(channel *ch);
    bool update_games();
    login *login_win;
    void ip_addr(std::string host); ///< set the ip address of the central server
    void main_loop(Gtk::Main kit); ///< main loop of the program
};

extern moros *game_data;

extern Glib::RefPtr<Gnome::Glade::Xml> refXml;

#endif // MOROS_H
